<template>
    <div id="header">
      <div class="heade-con">
        <div class="logo">
          <a href=""><img src="../../public/images/LOGO.png" /></a>
        </div>
        <div class="nav posa">
          <ul>
            <li><router-link to="/index">首页</router-link></li>
            <li><router-link to="/gyzc-list">公益众筹</router-link></li>
            <li><router-link to="/cop">常见问题</router-link></li>
            <li><router-link to="/ly-list">众筹咨询</router-link></li>
            <li><router-link to="/new_info">发布项目</router-link></li>
            <li> <div v-if="userCenter == 'true'"><router-link to="/user">个人中心</router-link></div></li>
          </ul>
        </div>
        <div class="search">
          <form action="">
            <input
              type="text"
              class="search-txt"
              value=""
              placeholder="找项目"
            />
            <input type="submit" class="search-but" value="" />
          </form>
        </div>
        <div class="index-login">

          <div style="margin: 0px -200px 0px 0px;">
            <span v-if="userCenter == 'true'" style="color: pink;">欢迎你，</span>
            <router-link to="login">{{msg}}</router-link>
            <span style="color: white">|</span>
            <span v-if="userCenter == 'false'"><router-link to="reg">注册</router-link>
            <span style="color: white">|</span>
            <router-link to="admin_login">后台管理</router-link>
            <span style="color: white">|</span></span>
            <label><a style="color:white" @click="tc()">退出</a></label>
          </div>
          
        </div>
      </div>
    </div>
</template>

<script>
export default {
    data()  {
        return {
            userCenter : 'false',
            msg:'未登录'
        } 
    },
    created(){
      if(!this.$checkCookie("token")){
        this.msg = '登录';
      }else{
        this.msg = localStorage.getItem("rLoginName");
        this.userCenter='true'
        }
    },
    methods : {
          tc(){
            this.$router.push('/index')
            location.reload();
            localStorage.removeItem('rLoginName')
            // 清除cookie
            this.$clearCookie("token")
        }
        
    },
    mounted()  {
    }
}
</script>

<style scoped>
    @import url("../../public/css//headbott.css");
</style>